home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Interfaces / Universal Interfaces 2.0a3 / Universal AIncludes / OSA.a < prev    next >
Encoding:
Text File  |  1994-11-11  |  49.0 KB  |  1,692 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        OSA.a
  3. ;
  4. ;    Copyright:    © 1984-1994 by Apple Computer, Inc.
  5. ;                All rights reserved.
  6. ;
  7. ;    Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8. ;
  9. ;    Bugs?:        If you find a problem with this file, send the file and version
  10. ;                information (from above) and the problem description to:
  11. ;
  12. ;                    Internet:    apple.bugs@applelink.apple.com
  13. ;                    AppleLink:    APPLE.BUGS
  14. ;
  15. ;
  16.  
  17.     IF &TYPE('__OSA__') = 'UNDEFINED' THEN
  18. __OSA__ SET 1
  19.  
  20.  
  21.     IF &TYPE('__ERRORS__') = 'UNDEFINED' THEN
  22.     include 'Errors.a'
  23.     ENDIF
  24. ;        include 'ConditionalMacros.a'                                ;
  25.  
  26.     IF &TYPE('__APPLEEVENTS__') = 'UNDEFINED' THEN
  27.     include 'AppleEvents.a'
  28.     ENDIF
  29. ;        include 'Types.a'                                            ;
  30. ;        include 'Memory.a'                                            ;
  31. ;            include 'MixedMode.a'                                    ;
  32. ;        include 'OSUtils.a'                                        ;
  33. ;        include 'Events.a'                                            ;
  34. ;            include 'Quickdraw.a'                                    ;
  35. ;                include 'QuickdrawText.a'                            ;
  36. ;        include 'EPPC.a'                                            ;
  37. ;            include 'PPCToolbox.a'                                    ;
  38. ;                include 'AppleTalk.a'                                ;
  39. ;            include 'Processes.a'                                    ;
  40. ;                include 'Files.a'                                    ;
  41. ;        include 'Notification.a'                                    ;
  42.  
  43.     IF &TYPE('__AEOBJECTS__') = 'UNDEFINED' THEN
  44.     include 'AEObjects.a'
  45.     ENDIF
  46.  
  47.     IF &TYPE('__COMPONENTS__') = 'UNDEFINED' THEN
  48.     include 'Components.a'
  49.     ENDIF
  50.  
  51. kOSAComponentType                EQU        'osa '
  52.  
  53. ; 0x73637074 
  54. kOSAGenericScriptingComponentSubtype EQU        'scpt'
  55.  
  56. ;    Type of script document files.    
  57. ; 0x6f736173 
  58. kOSAFileType                    EQU        'osas'
  59.  
  60. ;
  61. ;        Suite and event code of the RecordedText event. 
  62. ;        (See OSAStartRecording, below.)
  63. ;    
  64. ; 0x61736372 
  65. kOSASuite                        EQU        'ascr'
  66.  
  67. ; 0x72656364 
  68. kOSARecordedText                EQU        'recd'
  69.  
  70. ; Selector returns boolean 
  71. ; 0x6d6f6469 
  72. kOSAScriptIsModified            EQU        'modi'
  73.  
  74. ; Selector returns boolean 
  75. ; 0x63736372 
  76. kOSAScriptIsTypeCompiledScript    EQU        'cscr'
  77.  
  78. ; Selector returns boolean 
  79. ; 0x76616c75 
  80. kOSAScriptIsTypeScriptValue        EQU        'valu'
  81.  
  82. ; Selector returns boolean 
  83. ; 0x636e7478 
  84. kOSAScriptIsTypeScriptContext    EQU        'cntx'
  85.  
  86. ; Selector returns a DescType which may be passed to OSACoerceToDesc 
  87. ; 0x62657374 
  88. kOSAScriptBestType                EQU        'best'
  89.  
  90. ;
  91. ;        This selector is used to determine whether a script has source 
  92. ;        associated with it that when given to OSAGetSource, the call will not
  93. ;        fail.  The selector returns a boolean.
  94. ;    
  95. ; 0x67737263 
  96. kOSACanGetSource                EQU        'gsrc'
  97.  
  98. typeOSADialectInfo                EQU        'difo'                ;  0x6469666f   
  99. keyOSADialectName                EQU        'dnam'                ;  0x646e616d   
  100. keyOSADialectCode                EQU        'dcod'                ;  0x64636f64   
  101. keyOSADialectLangCode            EQU        'dlcd'                ;  0x646c6364   
  102. keyOSADialectScriptCode            EQU        'dscd'
  103.  
  104. ; Under the Open Scripting Architecture all error results are longs 
  105. ;
  106. ;        OSAIDs allow transparent manipulation of scripts associated with
  107. ;         various scripting systems.
  108. ;    
  109. kOSANullScript                    EQU        0
  110.  
  111. ; No -script constant. 
  112. kOSANullMode                    EQU        0                    ; sounds better 
  113. kOSAModeNull                    EQU        0                    ; tastes consistent 
  114.  
  115. ;
  116. ;        Some routines take flags that control their execution.  This constant
  117. ;        declares default mode settings are used.
  118. ;    
  119. ;*************************************************************************
  120. ;    Standard Script Errors
  121. ;**************************************************************************
  122. ;    It is recommended that scripting components use the following set of error
  123. ;    codes to signal failure when applicable.  This enables applications that
  124. ;    use the OSA API to deal with some class of script errors in a less than 
  125. ;    ad hoc manner.  Scripting components are of course encouraged to return
  126. ;    component-specific errors when these don't apply.
  127. ;*************************************************************************
  128. ;        Dynamic errors:
  129. ;
  130. ;    These errors result from data-dependent conditions and are typically
  131. ;    signaled at runtime.
  132. ;
  133. ;
  134. ;        Signaled when a value can't be coerced to the desired type. Similar
  135. ;          to errOSATypeError except results from coercion.
  136. ;    
  137. errOSACantCoerce                EQU        errAECoercionFail
  138.  
  139. ; Signaled when an object is not found in a container 
  140. errOSACantAccess                EQU        errAENoSuchObject
  141.  
  142. ;
  143. ;        Signaled when an object cannot be set in a container.  Same as 
  144. ;          AERegistry error errAEWriteDenied.
  145. ;    
  146. errOSACantAssign                EQU        -10006
  147.  
  148. ;
  149. ;        Signaled by user scripts or applications when no actual error code
  150. ;          is to be returned.  Simply means "an error has occurred".  Most useful
  151. ;          in conjunction with an error message from the application.
  152. ;    
  153. errOSAGeneralError                EQU        -2700
  154.  
  155. ; Signaled when there is an attempt to divide by zero 
  156. errOSADivideByZero                EQU        -2701
  157.  
  158. ; Signaled when integer or real value is too large to be represented 
  159. errOSANumericOverflow            EQU        -2702
  160.  
  161. ;
  162. ;        Signaled when application can't be launched or when it is remote and
  163. ;          program linking is not enabled.
  164. ;    
  165. errOSACantLaunch                EQU        -2703
  166.  
  167. ; Signaled when an application can't respond to AppleEvents 
  168. errOSAAppNotHighLevelEventAware    EQU        -2704
  169.  
  170. ; Signaled when an application's terminology resource is not readable 
  171. errOSACorruptTerminology        EQU        -2705
  172.  
  173. ; Signaled when the runtime stack overflows 
  174. errOSAStackOverflow                EQU        -2706
  175.  
  176. ; Signaled when a runtime internal data structure overflows 
  177. errOSAInternalTableOverflow        EQU        -2707
  178.  
  179. ;
  180. ;        Signaled when an intrinsic limitation is exceeded for the size of 
  181. ;          a value or data structure.
  182. ;    
  183. errOSADataBlockTooLarge            EQU        -2708
  184.  
  185. errOSACantGetTerminology        EQU        -2709
  186.  
  187. errOSACantCreate                EQU        -2710
  188.  
  189. ;        Component-specific dynamic script errors:
  190. ;
  191. ;    The range -2720 thru -2739 is reserved for component-specific runtime errors.
  192. ;    (Note that error codes from different scripting components in this range will
  193. ;    overlap.)
  194. ;
  195. ;        Static errors:
  196. ;
  197. ;    These errors comprise what are commonly thought of as parse and compile-
  198. ;    time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  199. ;    of these may also occur at runtime.
  200. ;
  201. ; Signaled when data was not the right type and coercion is not allowed 
  202. errOSATypeError                    EQU        errAEWrongDataType
  203.  
  204. ; Signaled when a message was sent to an object that didn't handle it 
  205. OSAMessageNotUnderstood            EQU        errAEEventNotHandled
  206.  
  207. ;
  208. ;        Signaled when a function to be returned doesn't exist.  (Probably only
  209. ;          useful in languages with first-class functions that distinguish between
  210. ;          functions and other values (two name spaces). This is different from
  211. ;          errOSAMessageNotUnderstood, which may be signaled when the method is
  212. ;          invoked.
  213. ;    
  214. OSAUndefinedHandler                EQU        errAEHandlerNotFound
  215.  
  216. ; Signaled when a container can never have the requested object 
  217. OSAIllegalAccess                EQU        errAEAccessorNotFound
  218.  
  219. ; Signaled when index was out of range. Specialization of errOSACantAccess. 
  220. OSAIllegalIndex                    EQU        errAEIllegalIndex
  221.  
  222. ; Signaled when a range is screwy. Specialization of errOSACantAccess. 
  223. OSAIllegalRange                    EQU        errAEImpossibleRange
  224.  
  225. ;
  226. ;        Signaled when an object can never be set in a container.  Same as 
  227. ;          AERegistry error errAENotModifiable.
  228. ;    
  229. OSAIllegalAssign                EQU        -10003
  230.  
  231. ;
  232. ;        Signaled when a syntax error occurs. (e.g. "Syntax error" or
  233. ;         "<this> can't go after <that>").
  234. ;    
  235. OSASyntaxError                    EQU        -2740
  236.  
  237. ;
  238. ;        Signaled when another form of syntax was expected. (e.g. "expected
  239. ;          a <type> but found <this>").
  240. ;    
  241. OSASyntaxTypeError                EQU        -2741
  242.  
  243. ; Signaled when a name or number is too long to be parsed 
  244. OSATokenTooLong                    EQU        -2742
  245.  
  246. ;
  247. ;        Signaled when a parameter is missing for a function invocation.  Note
  248. ;          that in some languages, this error may occur at runtime.
  249. ;    
  250. OSAMissingParameter                EQU        errAEDescNotFound
  251.  
  252. ;
  253. ;        Signaled when function is called with the wrong number of parameters,
  254. ;          or a parameter pattern cannot be matched.
  255. ;    
  256. OSAParameterMismatch            EQU        errAEWrongNumberArgs
  257.  
  258. ;
  259. ;        Signaled when a formal parameter, local variable, or instance variable
  260. ;          is specified more than once.
  261. ;    
  262. OSADuplicateParameter            EQU        -2750
  263.  
  264. ;
  265. ;        Signaled when a formal parameter, local variable, or instance variable
  266. ;          is specified more than once.
  267. ;    
  268. OSADuplicateProperty            EQU        -2751
  269.  
  270. ;
  271. ;        Signaled when more than one handler is defined with the same name in 
  272. ;          a scope where the language doesn't allow it.
  273. ;    
  274. OSADuplicateHandler                EQU        -2752
  275.  
  276. ; Signaled when a variable is accessed that has no value 
  277. OSAUndefinedVariable            EQU        -2753
  278.  
  279. ;
  280. ;        Signaled when a variable is declared inconsistently in the same scope,
  281. ;          such as both local and global.
  282. ;    
  283. OSAInconsistentDeclarations        EQU        -2754
  284.  
  285. ;
  286. ;        Signaled when illegal control flow occurs in an application (no catcher
  287. ;          for throw, non-lexical loop exit, etc.).
  288. ;    
  289. OSAControlFlowError                EQU        -2755
  290.  
  291. ;        Component-specific static script errors:
  292. ;
  293. ;    The range -2760 thru -2779 is reserved for component-specific parsing and
  294. ;    compile-time errors. (Note that error codes from different scripting
  295. ;    components in this range will overlap.)
  296. ;
  297. ;        Dialect-specific script errors:
  298. ;
  299. ;    The range -2780 thru -2799 is reserved for dialect specific error codes for
  300. ;    scripting components that support dialects. (Note that error codes from
  301. ;    different scripting components in this range will overlap, as well as error
  302. ;    codes from different dialects in the same scripting component.)
  303. ;
  304. ;*************************************************************************
  305. ;    OSA Interface Descriptions
  306. ;**************************************************************************
  307. ;    The OSA Interface is broken down into a required interface, and several
  308. ;    optional interfaces to support additional functionality.  A given scripting
  309. ;    component may choose to support only some of the optional interfaces in
  310. ;    addition to the basic interface.  The OSA Component Flags may be used to 
  311. ;    query the Component Manager to find a scripting component with a particular
  312. ;    capability, or determine if a particular scripting component supports a 
  313. ;    particular capability.
  314. ;*************************************************************************
  315. ; OSA Component Flags: 
  316. kOSASupportsCompiling            EQU        $0002
  317. kOSASupportsGetSource            EQU        $0004
  318. kOSASupportsAECoercion            EQU        $0008
  319. kOSASupportsAESending            EQU        $0010
  320. kOSASupportsRecording            EQU        $0020
  321. kOSASupportsConvenience            EQU        $0040
  322. kOSASupportsDialects            EQU        $0080
  323. kOSASupportsEventHandling        EQU        $0100
  324.  
  325. ; Component Selectors: 
  326. kOSASelectLoad                    EQU        $0001
  327. kOSASelectStore                    EQU        $0002
  328. kOSASelectExecute                EQU        $0003
  329. kOSASelectDisplay                EQU        $0004
  330. kOSASelectScriptError            EQU        $0005
  331. kOSASelectDispose                EQU        $0006
  332. kOSASelectSetScriptInfo            EQU        $0007
  333. kOSASelectGetScriptInfo            EQU        $0008
  334. kOSASelectSetActiveProc            EQU        $0009
  335. kOSASelectGetActiveProc            EQU        $000A
  336.  
  337. ; Compiling: 
  338. kOSASelectScriptingComponentName EQU        $0102
  339. kOSASelectCompile                EQU        $0103
  340. kOSASelectCopyID                EQU        $0104
  341.  
  342. ; GetSource: 
  343. kOSASelectGetSource                EQU        $0201
  344.  
  345. ; AECoercion: 
  346. kOSASelectCoerceFromDesc        EQU        $0301
  347. kOSASelectCoerceToDesc            EQU        $0302
  348.  
  349. ; AESending: 
  350. kOSASelectSetSendProc            EQU        $0401
  351. kOSASelectGetSendProc            EQU        $0402
  352. kOSASelectSetCreateProc            EQU        $0403
  353. kOSASelectGetCreateProc            EQU        $0404
  354. kOSASelectSetDefaultTarget        EQU        $0405
  355.  
  356. ; Recording: 
  357. kOSASelectStartRecording        EQU        $0501
  358. kOSASelectStopRecording            EQU        $0502
  359.  
  360. ; Convenience: 
  361. kOSASelectLoadExecute            EQU        $0601
  362. kOSASelectCompileExecute        EQU        $0602
  363. kOSASelectDoScript                EQU        $0603
  364.  
  365. ; Dialects: 
  366. kOSASelectSetCurrentDialect        EQU        $0701
  367. kOSASelectGetCurrentDialect        EQU        $0702
  368. kOSASelectAvailableDialects        EQU        $0703
  369. kOSASelectGetDialectInfo        EQU        $0704
  370. kOSASelectAvailableDialectCodeList EQU        $0705
  371.  
  372. ; Event Handling: 
  373. kOSASelectSetResumeDispatchProc    EQU        $0801
  374. kOSASelectGetResumeDispatchProc    EQU        $0802
  375. kOSASelectExecuteEvent            EQU        $0803
  376. kOSASelectDoEvent                EQU        $0804
  377. kOSASelectMakeContext            EQU        $0805
  378.  
  379. ; scripting component specific selectors are added beginning with this value  
  380. kOSASelectComponentSpecificStart EQU        $1001
  381.  
  382. ;        Mode Flags:
  383. ;
  384. ;    Warning: These should not conflict with the AESend mode flags in
  385. ;    AppleEvents.h, because we may want to use them as OSA mode flags too.
  386. ;
  387. ;
  388. ;        This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  389. ;          instruct the scripting component to not retain the "source" of an
  390. ;          expression.  This will cause the OSAGetSource call to return the error
  391. ;          errOSASourceNotAvailable if used.  However, some scripting components
  392. ;          may not retain the source anyway.  This is mainly used when either space
  393. ;          efficiency is desired, or a script is to be "locked" so that its
  394. ;          implementation may not be viewed.
  395. ;    
  396. kOSAModePreventGetSource        EQU        $00000001
  397.  
  398. ;
  399. ;        These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  400. ;          OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  401. ;          indicate whether or not the script may interact with the user, switch
  402. ;          layer or reconnect if necessary.  Any AppleEvents will be sent with the
  403. ;          corresponding AESend mode supplied.
  404. ;    
  405. kOSAModeNeverInteract            EQU        kAENeverInteract
  406. kOSAModeCanInteract                EQU        kAECanInteract
  407. kOSAModeAlwaysInteract            EQU        kAEAlwaysInteract
  408. kOSAModeDontReconnect            EQU        kAEDontReconnect
  409.  
  410. ;
  411. ;        This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  412. ;          OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  413. ;          indicate whether or not AppleEvents should be sent with the
  414. ;          kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  415. ;          opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  416. ;          provide a more convenient default, i.e. not supplying any mode
  417. ;          (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  418. ;          the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  419. ;          without kAECanSwitchLayer.
  420. ;    
  421. kOSAModeCantSwitchLayer            EQU        $00000040
  422.  
  423. ;
  424. ;        This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  425. ;          OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  426. ;          indicate whether or not AppleEvents should be sent with the kAEDontRecord
  427. ;          mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  428. ;          the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  429. ;          default, i.e. not supplying any mode (kOSAModeNull) means to send events
  430. ;          with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  431. ;          cause AESend to be called without kAEDontRecord.
  432. ;    
  433. kOSAModeDoRecord                EQU        $00001000
  434.  
  435. ;
  436. ;        This is a mode flag for OSACompile that indicates that a context should
  437. ;          be created as the result of compilation. All handler definitions are
  438. ;          inserted into the new context, and variables are initialized by
  439. ;          evaluating their initial values in a null context (i.e. they must be
  440. ;          constant expressions).
  441. ;    
  442. kOSAModeCompileIntoContext        EQU        $00000002
  443.  
  444. ;
  445. ;        This is a mode flag for OSACompile that indicates that the previous
  446. ;          script ID (input to OSACompile) should be augmented with any new
  447. ;          definitions in the sourceData rather than replaced with a new script.
  448. ;          This means that the previous script ID must designate a context.
  449. ;          The presence of this flag causes the kOSAModeCompileIntoContext flag
  450. ;          to be implicitly used, causing any new definitions to be initialized
  451. ;          in a null context.
  452. ;    
  453. kOSAModeAugmentContext            EQU        $00000004
  454.  
  455. ;
  456. ;        This mode flag may be passed to OSADisplay or OSADoScript to indicate
  457. ;          that output only need be human-readable, not re-compilable by OSACompile.
  458. ;          If used, output may be arbitrarily "beautified", e.g. quotes may be left
  459. ;          off of string values, long lists may have elipses, etc.
  460. ;    
  461. kOSAModeDisplayForHumans        EQU        $00000008
  462.  
  463. ;
  464. ;        This mode flag may be passed to OSAStore in the case where the scriptID
  465. ;          is a context.  This causes the context to be saved, but not the context's
  466. ;          parent context.  When the stored context is loaded back in, the parent
  467. ;          will be kOSANullScript.
  468. ;    
  469. kOSAModeDontStoreParent            EQU        $00010000
  470.  
  471. ;
  472. ;        This mode flag may be passed to OSAExecuteEvent to cause the event to
  473. ;          be dispatched to the direct object of the event. The direct object (or
  474. ;          subject attribute if the direct object is a non-object specifier) will
  475. ;          be resolved, and the resulting script object will be the recipient of
  476. ;          the message. The context argument to OSAExecuteEvent will serve as the
  477. ;          root of the lookup/resolution process.
  478. ;    
  479. kOSAModeDispatchToDirectObject    EQU        $00020000
  480.  
  481. ;
  482. ;        This mode flag may be passed to OSAExecuteEvent to indicate that
  483. ;          components do not have to get the data of object specifier arguments.
  484. ;    
  485. kOSAModeDontGetDataForArguments    EQU        $00040000
  486.  
  487. ;*************************************************************************
  488. ;    OSA Basic Scripting Interface
  489. ;**************************************************************************
  490. ;    Scripting components must at least support the Basic Scripting interface.
  491. ;*************************************************************************
  492. ;        Loading and Storing Scripts:
  493. ;
  494. ;    These routines allow scripts to be loaded and stored in their internal
  495. ;    (possibly compiled, non-text) representation.
  496. ;
  497. ; Resource type for scripts 
  498. kOSAScriptResourceType            EQU        kOSAGenericScriptingComponentSubtype
  499.  
  500. ;
  501. ;        Default type given to OSAStore which creates "generic" loadable script
  502. ;          data descriptors.
  503. ;    
  504. typeOSAGenericStorage            EQU        kOSAScriptResourceType
  505.  
  506.     IF GENERATING68K THEN
  507.         Macro
  508.         _OSALoad
  509.             dc.w     $2F3C
  510.             dc.w     $000C
  511.             dc.w     $0001
  512.             moveq    #0,d0
  513.             dc.w     $A82A
  514.         EndM
  515.     ELSE
  516.         IMPORT    OSALoad
  517.     ENDIF
  518.  
  519. ;
  520. ;        OSAComponentFunctionInline(kOSASelectLoad, 12);
  521. ;    
  522. ;        Errors:
  523. ;            badComponentInstance        invalid scripting component instance
  524. ;            errOSASystemError
  525. ;            errOSABadStorageType:        scriptData not for this scripting component
  526. ;            errOSACorruptData:            data seems to be corrupt
  527. ;            errOSADataFormatObsolete    script data format is no longer supported
  528. ;            errOSADataFormatTooNew        script data format is from a newer version
  529. ;        
  530. ;        ModeFlags:
  531. ;            kOSAModePreventGetSource
  532. ;    
  533.     IF GENERATING68K THEN
  534.         Macro
  535.         _OSAStore
  536.             dc.w     $2F3C
  537.             dc.w     $0010
  538.             dc.w     $0002
  539.             moveq    #0,d0
  540.             dc.w     $A82A
  541.         EndM
  542.     ELSE
  543.         IMPORT    OSAStore
  544.     ENDIF
  545.  
  546. ;
  547. ;        OSAComponentFunctionInline(kOSASelectStore, 16);
  548. ;    
  549. ;        Errors:
  550. ;            badComponentInstance    invalid scripting component instance
  551. ;            errOSASystemError
  552. ;            errOSAInvalidID
  553. ;            errOSABadStorageType:    desiredType not for this scripting component
  554. ;        
  555. ;        ModeFlags:
  556. ;            kOSAModePreventGetSource
  557. ;            kOSAModeDontStoreParent
  558. ;    
  559. ; Executing Scripts: 
  560.     IF GENERATING68K THEN
  561.         Macro
  562.         _OSAExecute
  563.             dc.w     $2F3C
  564.             dc.w     $0010
  565.             dc.w     $0003
  566.             moveq    #0,d0
  567.             dc.w     $A82A
  568.         EndM
  569.     ELSE
  570.         IMPORT    OSAExecute
  571.     ENDIF
  572.  
  573. ;
  574. ;        OSAComponentFunctionInline(kOSASelectExecute, 16);
  575. ;        This call runs a script.  The contextID represents the environment
  576. ;        with which global variables in the script are resolved.  The constant
  577. ;        kOSANullScript may be used for the contextID if the application wishes
  578. ;        to not deal with context directly (a default one is associated with each
  579. ;        scripting component instance).  The resultingScriptValueID is the 
  580. ;        result of evaluation, and contains a value which may be displayed using
  581. ;        the OSAGetSource call.  The modeFlags convey scripting component
  582. ;        specific information.
  583. ;    
  584. ;        Errors:
  585. ;            badComponentInstance    invalid scripting component instance
  586. ;            errOSASystemError
  587. ;            errOSAInvalidID
  588. ;            errOSAScriptError:        the executing script got an error
  589. ;    
  590. ;        ModeFlags:
  591. ;            kOSAModeNeverInteract
  592. ;            kOSAModeCanInteract
  593. ;            kOSAModeAlwaysInteract
  594. ;            kOSAModeCantSwitchLayer
  595. ;            kOSAModeDontReconnect
  596. ;            kOSAModeDoRecord
  597. ;    
  598. ; Displaying results: 
  599.     IF GENERATING68K THEN
  600.         Macro
  601.         _OSADisplay
  602.             dc.w     $2F3C
  603.             dc.w     $0010
  604.             dc.w     $0004
  605.             moveq    #0,d0
  606.             dc.w     $A82A
  607.         EndM
  608.     ELSE
  609.         IMPORT    OSADisplay
  610.     ENDIF
  611.  
  612. ;
  613. ;        OSAComponentFunctionInline(kOSASelectDisplay, 16);
  614. ;        This call is used to convert results (script value IDs) into displayable
  615. ;        text. The desiredType should be at least typeChar, and modeFlags are
  616. ;        scripting system specific flags to control the formatting of the
  617. ;        resulting text. This call differs from OSAGetSource in that (1) it
  618. ;        always produces at least typeChar, (2) is only works on script values,
  619. ;        (3) it may display it's output in non-compilable form (e.g. without
  620. ;        string quotes, elipses inserted in long and/or circular lists, etc.) and
  621. ;        (4) it is required by the basic scripting interface.
  622. ;    
  623. ;        Errors:
  624. ;            badComponentInstance    invalid scripting component instance
  625. ;            errOSASystemError
  626. ;            errOSAInvalidID
  627. ;            errAECoercionFail:        desiredType not supported by scripting component
  628. ;    
  629. ;        ModeFlags:
  630. ;            kOSAModeDisplayForHumans
  631. ;    
  632. ; Getting Error Information: 
  633.     IF GENERATING68K THEN
  634.         Macro
  635.         _OSAScriptError
  636.             dc.w     $2F3C
  637.             dc.w     $000C
  638.             dc.w     $0005
  639.             moveq    #0,d0
  640.             dc.w     $A82A
  641.         EndM
  642.     ELSE
  643.         IMPORT    OSAScriptError
  644.     ENDIF
  645.  
  646. ;
  647. ;        OSAComponentFunctionInline(kOSASelectScriptError, 12);
  648. ;        Whenever script execution returns errOSAExecutionError, this routine
  649. ;        may be used to get information about that error.  The selector describes
  650. ;        the type of information desired about the error (various selectors are
  651. ;        listed below).  The desiredType indicates the data type of the result
  652. ;        desired for that selector.
  653. ;    
  654. ;        Errors:
  655. ;            badComponentInstance    invalid scripting component instance
  656. ;            errOSASystemError
  657. ;            errOSABadSelector:        selector not supported by scripting component
  658. ;            errAECoercionFail:        desiredType not supported by scripting component
  659. ;    
  660. ; OSAScriptError selectors: 
  661. ;
  662. ;        This selector is used to determine the error number of a script error.
  663. ;        These error numbers may be either system error numbers, or error numbers
  664. ;        that are scripting component specific.
  665. ;        Required desiredTypes:    
  666. ;              typeShortInteger
  667. ;    
  668. kOSAErrorNumber                    EQU        keyErrorNumber
  669.  
  670. ;
  671. ;        This selector is used to determine the full error message associated
  672. ;        with the error number.  It should include the name of the application
  673. ;        which caused the error, as well as the specific error that occurred.
  674. ;        This selector is sufficient for simple error reporting (but see
  675. ;        kOSAErrorBriefMessage, below).
  676. ;        Required desiredTypes:
  677. ;            typeChar                    error message string
  678. ;    
  679. kOSAErrorMessage                EQU        keyErrorString
  680.  
  681. ;
  682. ;        This selector is used to determine a brief error message associated with
  683. ;        the error number.  This message and should not mention the name of the
  684. ;        application which caused the error, any partial results or offending
  685. ;        object (see kOSAErrorApp, kOSAErrorPartialResult and
  686. ;        kOSAErrorOffendingObject, below).
  687. ;        Required desiredTypes:
  688. ;              typeChar                    brief error message string
  689. ;    
  690. ;  0x65727262  
  691. kOSAErrorBriefMessage            EQU        'errb'
  692.  
  693. ;
  694. ;        This selector is used to determine which application actually got the
  695. ;        error (if it was the result of an AESend), or the current application
  696. ;        if ....
  697. ;        Required desiredTypes:
  698. ;              typeProcessSerialNumber        PSN of the errant application
  699. ;              typeChar                    name of the errant application
  700. ;    
  701. ;  0x65726170  
  702. kOSAErrorApp                    EQU        'erap'
  703.  
  704. ;
  705. ;        This selector is used to determine any partial result returned by an 
  706. ;        operation. If an AESend call failed, but a partial result was returned,
  707. ;        then the partial result may be returned as an AEDesc.
  708. ;        Required desiredTypes:
  709. ;              typeBest                    AEDesc of any partial result
  710. ;    
  711. ;  0x70746c72   
  712. kOSAErrorPartialResult            EQU        'ptlr'
  713.  
  714. ;
  715. ;        This selector is used to determine any object which caused the error
  716. ;        that may have been indicated by an application.  The result is an 
  717. ;        AEDesc.
  718. ;        Required desiredTypes:
  719. ;              typeBest                    AEDesc of any offending object
  720. ;    
  721. ;  0x65726f62   
  722. kOSAErrorOffendingObject        EQU        'erob'
  723.  
  724. ;
  725. ;        This selector is used to determine the type expected by a coercion 
  726. ;        operation if a type error occurred.
  727. ;    
  728. ;  0x65727274   
  729. kOSAErrorExpectedType            EQU        'errt'
  730.  
  731. ;
  732. ;        This selector is used to determine the source text range (start and 
  733. ;        end positions) of where the error occurred.
  734. ;        Required desiredTypes:
  735. ;              typeOSAErrorRange
  736. ;    
  737. ;  0x65726e67  
  738. kOSAErrorRange                    EQU        'erng'
  739.  
  740. ;
  741. ;        An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  742. ;        of type short.
  743. ;    
  744. ;  0x65726e67   
  745. typeOSAErrorRange                EQU        'erng'
  746.  
  747. ; Field of a typeOSAErrorRange record of typeShortInteger 
  748. ;  0x73726373    
  749. keyOSASourceStart                EQU        'srcs'
  750.  
  751. ; Field of a typeOSAErrorRange record of typeShortInteger 
  752. ;  0x73726365   
  753. keyOSASourceEnd                    EQU        'srce'
  754.  
  755. ; Disposing Script IDs: 
  756.     IF GENERATING68K THEN
  757.         Macro
  758.         _OSADispose
  759.             dc.w     $2F3C
  760.             dc.w     $0004
  761.             dc.w     $0006
  762.             moveq    #0,d0
  763.             dc.w     $A82A
  764.         EndM
  765.     ELSE
  766.         IMPORT    OSADispose
  767.     ENDIF
  768.  
  769. ;
  770. ;        OSAComponentFunctionInline(kOSASelectDispose, 4);
  771. ;        Disposes a script or context.
  772. ;    
  773. ;        Errors:
  774. ;            badComponentInstance    invalid scripting component instance
  775. ;            errOSASystemError
  776. ;            errOSAInvalidID
  777. ;    
  778. ; Getting and Setting Script Information: 
  779.     IF GENERATING68K THEN
  780.         Macro
  781.         _OSASetScriptInfo
  782.             dc.w     $2F3C
  783.             dc.w     $000C
  784.             dc.w     $0007
  785.             moveq    #0,d0
  786.             dc.w     $A82A
  787.         EndM
  788.     ELSE
  789.         IMPORT    OSASetScriptInfo
  790.     ENDIF
  791.  
  792. ;
  793. ;        OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  794. ;    
  795. ;        Errors:
  796. ;            badComponentInstance    invalid scripting component instance
  797. ;            errOSASystemError
  798. ;            errOSAInvalidID
  799. ;            errOSABadSelector:        selector not supported by scripting component
  800. ;                                    or selector not for this scriptID
  801. ;    
  802.     IF GENERATING68K THEN
  803.         Macro
  804.         _OSAGetScriptInfo
  805.             dc.w     $2F3C
  806.             dc.w     $000C
  807.             dc.w     $0008
  808.             moveq    #0,d0
  809.             dc.w     $A82A
  810.         EndM
  811.     ELSE
  812.         IMPORT    OSAGetScriptInfo
  813.     ENDIF
  814.  
  815. ;
  816. ;        OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  817. ;    
  818. ;        Errors:
  819. ;            badComponentInstance    invalid scripting component instance
  820. ;            errOSASystemError
  821. ;            errOSAInvalidID
  822. ;            errOSABadSelector:        selector not supported by scripting component
  823. ;                                    or selector not for this scriptID
  824. ;    
  825. ; Manipulating the ActiveProc:
  826. ;
  827. ;    Scripting systems will supply default values for these procedures if they
  828. ;    are not set by the client:
  829. ;
  830.     IF GENERATING68K THEN
  831.         Macro
  832.         _OSASetActiveProc
  833.             dc.w     $2F3C
  834.             dc.w     $0008
  835.             dc.w     $0009
  836.             moveq    #0,d0
  837.             dc.w     $A82A
  838.         EndM
  839.     ELSE
  840.         IMPORT    OSASetActiveProc
  841.     ENDIF
  842.  
  843. ;
  844. ;        OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  845. ;        If activeProc is nil, the default activeProc is used.
  846. ;    
  847. ;        Errors:
  848. ;            badComponentInstance    invalid scripting component instance
  849. ;            errOSASystemError
  850. ;    
  851.     IF GENERATING68K THEN
  852.         Macro
  853.         _OSAGetActiveProc
  854.             dc.w     $2F3C
  855.             dc.w     $0008
  856.             dc.w     $000A
  857.             moveq    #0,d0
  858.             dc.w     $A82A
  859.         EndM
  860.     ELSE
  861.         IMPORT    OSAGetActiveProc
  862.     ENDIF
  863.  
  864. ;
  865. ;        OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  866. ;    
  867. ;        Errors:
  868. ;            badComponentInstance    invalid scripting component instance
  869. ;            errOSASystemError
  870. ;    
  871. ;*************************************************************************
  872. ;    OSA Optional Compiling Interface
  873. ;**************************************************************************
  874. ;    Scripting components that support the Compiling interface have the 
  875. ;    kOSASupportsCompiling bit set in it's ComponentDescription.
  876. ;*************************************************************************
  877.     IF GENERATING68K THEN
  878.         Macro
  879.         _OSAScriptingComponentName
  880.             dc.w     $2F3C
  881.             dc.w     $0004
  882.             dc.w     $0102
  883.             moveq    #0,d0
  884.             dc.w     $A82A
  885.         EndM
  886.     ELSE
  887.         IMPORT    OSAScriptingComponentName
  888.     ENDIF
  889.  
  890. ;
  891. ;        OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  892. ;        Given a scripting component, this routine returns the name of that
  893. ;        scripting component in a type that is coercable to text (typeChar).
  894. ;        The generic scripting component returns the name of the default
  895. ;        scripting component.  This name should be sufficient to convey to the
  896. ;        user the kind of script (syntax) he is expected to write.
  897. ;    
  898. ;        Errors:
  899. ;            badComponentInstance    invalid scripting component instance
  900. ;            errOSASystemError
  901. ;    
  902.     IF GENERATING68K THEN
  903.         Macro
  904.         _OSACompile
  905.             dc.w     $2F3C
  906.             dc.w     $000C
  907.             dc.w     $0602
  908.             moveq    #0,d0
  909.             dc.w     $A82A
  910.         EndM
  911.     ELSE
  912.         IMPORT    OSACompile
  913.     ENDIF
  914.  
  915. ;
  916. ;        OSAComponentFunctionInline(kOSASelectCompile, 12);
  917. ;        Coerces input desc (possibly text) into a script's internal format.
  918. ;        Once compiled, the script is ready to run.  The modeFlags convey
  919. ;        scripting component specific information.  The previous script ID
  920. ;        (result parameter) is made to refer to the newly compiled script,
  921. ;        unless it was originally kOSANullScript.  In this case a new script
  922. ;        ID is created and used.
  923. ;    
  924. ;        Errors:
  925. ;            badComponentInstance    invalid scripting component instance
  926. ;            errOSASystemError
  927. ;            errAECoercionFail:        sourceData is not compilable
  928. ;            errOSAScriptError:        sourceData was a bad script (syntax error)
  929. ;            errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  930. ;                                    valid on input
  931. ;    
  932. ;        ModeFlags:
  933. ;            kOSAModePreventGetSource
  934. ;            kOSAModeCompileIntoContext
  935. ;            kOSAModeAugmentContext
  936. ;            kOSAModeNeverInteract
  937. ;            kOSAModeCanInteract
  938. ;            kOSAModeAlwaysInteract
  939. ;            kOSAModeCantSwitchLayer
  940. ;            kOSAModeDontReconnect
  941. ;            kOSAModeDoRecord
  942. ;    
  943.     IF GENERATING68K THEN
  944.         Macro
  945.         _OSACopyID
  946.             dc.w     $2F3C
  947.             dc.w     $0008
  948.             dc.w     $0104
  949.             moveq    #0,d0
  950.             dc.w     $A82A
  951.         EndM
  952.     ELSE
  953.         IMPORT    OSACopyID
  954.     ENDIF
  955.  
  956. ;
  957. ;        OSAComponentFunctionInline(kOSASelectCopyID, 8);
  958. ;        If toID is a reference to kOSANullScript then it is updated to have a
  959. ;        new scriptID value.  This call can be used to perform undo or revert
  960. ;        operations on scripts. 
  961. ;    
  962. ;        Errors:
  963. ;            badComponentInstance    invalid scripting component instance
  964. ;            errOSASystemError
  965. ;            errOSAInvalidID
  966. ;    
  967. ;*************************************************************************
  968. ;    OSA Optional GetSource Interface
  969. ;**************************************************************************
  970. ;    Scripting components that support the GetSource interface have the 
  971. ;    kOSASupportsGetSource bit set in it's ComponentDescription.
  972. ;*************************************************************************
  973.     IF GENERATING68K THEN
  974.         Macro
  975.         _OSAGetSource
  976.             dc.w     $2F3C
  977.             dc.w     $000C
  978.             dc.w     $0201
  979.             moveq    #0,d0
  980.             dc.w     $A82A
  981.         EndM
  982.     ELSE
  983.         IMPORT    OSAGetSource
  984.     ENDIF
  985.  
  986. ;
  987. ;        OSAComponentFunctionInline(kOSASelectGetSource, 12);
  988. ;        This routine causes a compiled script to be output in a form (possibly
  989. ;        text) such that it is suitable to be passed back to OSACompile.
  990. ;
  991. ;        Errors:
  992. ;            badComponentInstance    invalid scripting component instance
  993. ;            errOSASystemError
  994. ;            errOSAInvalidID
  995. ;            errOSASourceNotAvailable    can't get source for this scriptID
  996. ;    
  997. ;*************************************************************************
  998. ;    OSA Optional AECoercion Interface
  999. ;**************************************************************************
  1000. ;    Scripting components that support the AECoercion interface have the 
  1001. ;    kOSASupportsAECoercion bit set in it's ComponentDescription.
  1002. ;*************************************************************************
  1003.     IF GENERATING68K THEN
  1004.         Macro
  1005.         _OSACoerceFromDesc
  1006.             dc.w     $2F3C
  1007.             dc.w     $000C
  1008.             dc.w     $0301
  1009.             moveq    #0,d0
  1010.             dc.w     $A82A
  1011.         EndM
  1012.     ELSE
  1013.         IMPORT    OSACoerceFromDesc
  1014.     ENDIF
  1015.  
  1016. ;
  1017. ;        OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  1018. ;        This routine causes script data to be coerced into a script value.
  1019. ;        If the scriptData is an AppleEvent, then the resultingScriptID is a
  1020. ;        compiled script ID (mode flags for OSACompile may be used in this case).
  1021. ;        Other scriptData descriptors create script value IDs.
  1022. ;    
  1023. ;        Errors:
  1024. ;            badComponentInstance    invalid scripting component instance
  1025. ;            errOSASystemError
  1026. ;    
  1027. ;        ModeFlags:
  1028. ;            kOSAModePreventGetSource
  1029. ;            kOSAModeCompileIntoContext
  1030. ;            kOSAModeNeverInteract
  1031. ;            kOSAModeCanInteract
  1032. ;            kOSAModeAlwaysInteract
  1033. ;            kOSAModeCantSwitchLayer
  1034. ;            kOSAModeDontReconnect
  1035. ;            kOSAModeDoRecord
  1036. ;    
  1037.     IF GENERATING68K THEN
  1038.         Macro
  1039.         _OSACoerceToDesc
  1040.             dc.w     $2F3C
  1041.             dc.w     $0010
  1042.             dc.w     $0302
  1043.             moveq    #0,d0
  1044.             dc.w     $A82A
  1045.         EndM
  1046.     ELSE
  1047.         IMPORT    OSACoerceToDesc
  1048.     ENDIF
  1049.  
  1050. ;
  1051. ;        OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  1052. ;        This routine causes a script value to be coerced into any desired form.
  1053. ;        If the scriptID denotes a compiled script, then it may be coerced to 
  1054. ;        typeAppleEvent.
  1055. ;    
  1056. ;        Errors:
  1057. ;            badComponentInstance    invalid scripting component instance
  1058. ;            errOSASystemError
  1059. ;            errOSAInvalidID
  1060. ;    
  1061. ;*************************************************************************
  1062. ;    OSA Optional AESending Interface
  1063. ;**************************************************************************
  1064. ;    Scripting components that support the AESending interface have the 
  1065. ;    kOSASupportsAESending bit set in it's ComponentDescription.
  1066. ;*************************************************************************
  1067. ;
  1068. ;    Scripting systems will supply default values for these procedures if they
  1069. ;    are not set by the client:
  1070. ;
  1071.     IF GENERATING68K THEN
  1072.         Macro
  1073.         _OSASetSendProc
  1074.             dc.w     $2F3C
  1075.             dc.w     $0008
  1076.             dc.w     $0401
  1077.             moveq    #0,d0
  1078.             dc.w     $A82A
  1079.         EndM
  1080.     ELSE
  1081.         IMPORT    OSASetSendProc
  1082.     ENDIF
  1083.  
  1084. ;
  1085. ;        OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1086. ;        If sendProc is nil, the default sendProc is used.
  1087. ;    
  1088. ;        Errors:
  1089. ;            badComponentInstance    invalid scripting component instance
  1090. ;            errOSASystemError
  1091. ;    
  1092.     IF GENERATING68K THEN
  1093.         Macro
  1094.         _OSAGetSendProc
  1095.             dc.w     $2F3C
  1096.             dc.w     $0008
  1097.             dc.w     $0402
  1098.             moveq    #0,d0
  1099.             dc.w     $A82A
  1100.         EndM
  1101.     ELSE
  1102.         IMPORT    OSAGetSendProc
  1103.     ENDIF
  1104.  
  1105. ;
  1106. ;        OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1107. ;    
  1108. ;        Errors:
  1109. ;            badComponentInstance    invalid scripting component instance
  1110. ;            errOSASystemError
  1111. ;    
  1112.     IF GENERATING68K THEN
  1113.         Macro
  1114.         _OSASetCreateProc
  1115.             dc.w     $2F3C
  1116.             dc.w     $0008
  1117.             dc.w     $0403
  1118.             moveq    #0,d0
  1119.             dc.w     $A82A
  1120.         EndM
  1121.     ELSE
  1122.         IMPORT    OSASetCreateProc
  1123.     ENDIF
  1124.  
  1125. ;
  1126. ;        OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1127. ;        If createProc is nil, the default createProc is used.
  1128. ;    
  1129. ;        Errors:
  1130. ;            badComponentInstance    invalid scripting component instance
  1131. ;            errOSASystemError
  1132. ;    
  1133.     IF GENERATING68K THEN
  1134.         Macro
  1135.         _OSAGetCreateProc
  1136.             dc.w     $2F3C
  1137.             dc.w     $0008
  1138.             dc.w     $0404
  1139.             moveq    #0,d0
  1140.             dc.w     $A82A
  1141.         EndM
  1142.     ELSE
  1143.         IMPORT    OSAGetCreateProc
  1144.     ENDIF
  1145.  
  1146. ;
  1147. ;        OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1148. ;    
  1149. ;        Errors:
  1150. ;            badComponentInstance    invalid scripting component instance
  1151. ;            errOSASystemError
  1152. ;    
  1153.     IF GENERATING68K THEN
  1154.         Macro
  1155.         _OSASetDefaultTarget
  1156.             dc.w     $2F3C
  1157.             dc.w     $0004
  1158.             dc.w     $0405
  1159.             moveq    #0,d0
  1160.             dc.w     $A82A
  1161.         EndM
  1162.     ELSE
  1163.         IMPORT    OSASetDefaultTarget
  1164.     ENDIF
  1165.  
  1166. ;
  1167. ;        OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1168. ;        This routine sets the default target application for AE sending.
  1169. ;        It also establishes the default target from which terminologies come.
  1170. ;        It is effectively like having an AppleScript "tell" statement around
  1171. ;        the entire program.  If this routine is not called, or if the target 
  1172. ;        is a null AEDesc, then the current application is the default target.
  1173. ;    
  1174. ;        Errors:
  1175. ;            badComponentInstance    invalid scripting component instance
  1176. ;            errOSASystemError
  1177. ;    
  1178. ;*************************************************************************
  1179. ;    OSA Optional Recording Interface
  1180. ;**************************************************************************
  1181. ;    Scripting components that support the Recording interface have the 
  1182. ;    kOSASupportsRecording bit set in it's ComponentDescription.
  1183. ;*************************************************************************
  1184.     IF GENERATING68K THEN
  1185.         Macro
  1186.         _OSAStartRecording
  1187.             dc.w     $2F3C
  1188.             dc.w     $0004
  1189.             dc.w     $0501
  1190.             moveq    #0,d0
  1191.             dc.w     $A82A
  1192.         EndM
  1193.     ELSE
  1194.         IMPORT    OSAStartRecording
  1195.     ENDIF
  1196.  
  1197. ;
  1198. ;        OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1199. ;        Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1200. ;        new script ID is created and returned.  If the current application has
  1201. ;        a handler for the kOSARecordedText event, then kOSARecordedText events
  1202. ;        are sent to the application containing the text of each AppleEvent 
  1203. ;        recorded.
  1204. ;    
  1205. ;        Errors:
  1206. ;            badComponentInstance    invalid scripting component instance
  1207. ;            errOSASystemError
  1208. ;            errOSAInvalidID
  1209. ;            errOSARecordingIsAlreadyOn
  1210. ;    
  1211.     IF GENERATING68K THEN
  1212.         Macro
  1213.         _OSAStopRecording
  1214.             dc.w     $2F3C
  1215.             dc.w     $0004
  1216.             dc.w     $0502
  1217.             moveq    #0,d0
  1218.             dc.w     $A82A
  1219.         EndM
  1220.     ELSE
  1221.         IMPORT    OSAStopRecording
  1222.     ENDIF
  1223.  
  1224. ;
  1225. ;        OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1226. ;        If compiledScriptID is not being recorded into or recording is not
  1227. ;        currently on, no error is returned.
  1228. ;    
  1229. ;        Errors:
  1230. ;            badComponentInstance    invalid scripting component instance
  1231. ;            errOSASystemError
  1232. ;            errOSAInvalidID
  1233. ;    
  1234. ;*************************************************************************
  1235. ;    OSA Optional Convenience Interface
  1236. ;**************************************************************************
  1237. ;    Scripting components that support the Convenience interface have the 
  1238. ;    kOSASupportsConvenience bit set in it's ComponentDescription.
  1239. ;*************************************************************************
  1240.     IF GENERATING68K THEN
  1241.         Macro
  1242.         _OSALoadExecute
  1243.             dc.w     $2F3C
  1244.             dc.w     $0010
  1245.             dc.w     $0601
  1246.             moveq    #0,d0
  1247.             dc.w     $A82A
  1248.         EndM
  1249.     ELSE
  1250.         IMPORT    OSALoadExecute
  1251.     ENDIF
  1252.  
  1253. ;
  1254. ;        OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1255. ;        This routine is effectively equivalent to calling OSALoad followed by
  1256. ;        OSAExecute.  After execution, the compiled source is disposed.  Only the
  1257. ;        resulting value ID is retained.
  1258. ;    
  1259. ;        Errors:
  1260. ;            badComponentInstance        invalid scripting component instance
  1261. ;            errOSASystemError
  1262. ;            errOSABadStorageType:        scriptData not for this scripting component
  1263. ;            errOSACorruptData:            data seems to be corrupt
  1264. ;            errOSADataFormatObsolete    script data format is no longer supported
  1265. ;            errOSADataFormatTooNew        script data format is from a newer version
  1266. ;            errOSAInvalidID
  1267. ;            errOSAScriptError:            the executing script got an error
  1268. ;    
  1269. ;        ModeFlags:
  1270. ;            kOSAModeNeverInteract
  1271. ;            kOSAModeCanInteract
  1272. ;            kOSAModeAlwaysInteract
  1273. ;            kOSAModeCantSwitchLayer
  1274. ;            kOSAModeDontReconnect
  1275. ;            kOSAModeDoRecord
  1276. ;    
  1277.     IF GENERATING68K THEN
  1278.         Macro
  1279.         _OSACompileExecute
  1280.             dc.w     $2F3C
  1281.             dc.w     $0010
  1282.             dc.w     $0602
  1283.             moveq    #0,d0
  1284.             dc.w     $A82A
  1285.         EndM
  1286.     ELSE
  1287.         IMPORT    OSACompileExecute
  1288.     ENDIF
  1289.  
  1290. ;
  1291. ;        OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1292. ;        This routine is effectively equivalent to calling OSACompile followed by
  1293. ;        OSAExecute.  After execution, the compiled source is disposed.  Only the
  1294. ;        resulting value ID is retained.
  1295. ;    
  1296. ;        Errors:
  1297. ;            badComponentInstance    invalid scripting component instance
  1298. ;            errOSASystemError
  1299. ;            errAECoercionFail:        sourceData is not compilable
  1300. ;            errOSAScriptError:        sourceData was a bad script (syntax error)
  1301. ;            errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1302. ;                                    valid on input
  1303. ;            errOSAScriptError:        the executing script got an error
  1304. ;    
  1305. ;        ModeFlags:
  1306. ;            kOSAModeNeverInteract
  1307. ;            kOSAModeCanInteract
  1308. ;            kOSAModeAlwaysInteract
  1309. ;            kOSAModeCantSwitchLayer
  1310. ;            kOSAModeDontReconnect
  1311. ;            kOSAModeDoRecord
  1312. ;    
  1313.     IF GENERATING68K THEN
  1314.         Macro
  1315.         _OSADoScript
  1316.             dc.w     $2F3C
  1317.             dc.w     $0014
  1318.             dc.w     $0603
  1319.             moveq    #0,d0
  1320.             dc.w     $A82A
  1321.         EndM
  1322.     ELSE
  1323.         IMPORT    OSADoScript
  1324.     ENDIF
  1325.  
  1326. ;
  1327. ;        OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1328. ;        This routine is effectively equivalent to calling OSACompile followed by
  1329. ;        OSAExecute and then OSADisplay.  After execution, the compiled source
  1330. ;        and the resulting value are is disposed.  Only the resultingText
  1331. ;        descriptor is retained.  If a script error occur during processing, the 
  1332. ;        resultingText gets the error message of the error, and errOSAScriptError
  1333. ;        is returned.  OSAScriptError may still be used to extract more 
  1334. ;        information about the particular error.
  1335. ;    
  1336. ;        Errors:
  1337. ;            badComponentInstance    invalid scripting component instance
  1338. ;            errOSASystemError
  1339. ;            errAECoercionFail:        sourceData is not compilable or 
  1340. ;                                    desiredType not supported by scripting component
  1341. ;            errOSAScriptError:        sourceData was a bad script (syntax error)
  1342. ;            errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1343. ;                                    valid on input
  1344. ;            errOSAScriptError:        the executing script got an error
  1345. ;    
  1346. ;        ModeFlags:
  1347. ;            kOSAModeNeverInteract
  1348. ;            kOSAModeCanInteract
  1349. ;            kOSAModeAlwaysInteract
  1350. ;            kOSAModeCantSwitchLayer
  1351. ;            kOSAModeDontReconnect
  1352. ;            kOSAModeDoRecord
  1353. ;            kOSAModeDisplayForHumans
  1354. ;    
  1355. ;*************************************************************************
  1356. ;    OSA Optional Dialects Interface
  1357. ;**************************************************************************
  1358. ;    Scripting components that support the Dialects interface have the 
  1359. ;    kOSASupportsDialects bit set in it's ComponentDescription.
  1360. ;*************************************************************************
  1361. ;
  1362. ;    These calls allows an scripting component that supports different dialects
  1363. ;    to dynamically switch between those dialects.  Although this interface is
  1364. ;    specified, the particular dialect codes are scripting component dependent.
  1365. ;
  1366.     IF GENERATING68K THEN
  1367.         Macro
  1368.         _OSASetCurrentDialect
  1369.             dc.w     $2F3C
  1370.             dc.w     $0002
  1371.             dc.w     $0701
  1372.             moveq    #0,d0
  1373.             dc.w     $A82A
  1374.         EndM
  1375.     ELSE
  1376.         IMPORT    OSASetCurrentDialect
  1377.     ENDIF
  1378.  
  1379. ;
  1380. ;        OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1381. ;    
  1382. ;        Errors:
  1383. ;            badComponentInstance    invalid scripting component instance
  1384. ;            errOSASystemError
  1385. ;            errOSANoSuchDialect:    invalid dialectCode
  1386. ;    
  1387.     IF GENERATING68K THEN
  1388.         Macro
  1389.         _OSAGetCurrentDialect
  1390.             dc.w     $2F3C
  1391.             dc.w     $0004
  1392.             dc.w     $0702
  1393.             moveq    #0,d0
  1394.             dc.w     $A82A
  1395.         EndM
  1396.     ELSE
  1397.         IMPORT    OSAGetCurrentDialect
  1398.     ENDIF
  1399.  
  1400. ;
  1401. ;        OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1402. ;    
  1403. ;        Errors:
  1404. ;            badComponentInstance    invalid scripting component instance
  1405. ;            errOSASystemError
  1406. ;    
  1407.     IF GENERATING68K THEN
  1408.         Macro
  1409.         _OSAAvailableDialects
  1410.             dc.w     $2F3C
  1411.             dc.w     $0004
  1412.             dc.w     $0703
  1413.             moveq    #0,d0
  1414.             dc.w     $A82A
  1415.         EndM
  1416.     ELSE
  1417.         IMPORT    OSAAvailableDialects
  1418.     ENDIF
  1419.  
  1420. ;
  1421. ;        OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1422. ;        This call return an AEList containing information about each of the
  1423. ;        currently available dialects of a scripting component.  Each item
  1424. ;        is an AERecord of typeOSADialectInfo that contains at least the fields
  1425. ;        keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1426. ;        keyOSADialectScriptCode.
  1427. ;    
  1428. ;        Errors:
  1429. ;            badComponentInstance    invalid scripting component instance
  1430. ;            errOSASystemError
  1431. ;    
  1432.     IF GENERATING68K THEN
  1433.         Macro
  1434.         _OSAGetDialectInfo
  1435.             dc.w     $2F3C
  1436.             dc.w     $000A
  1437.             dc.w     $0704
  1438.             moveq    #0,d0
  1439.             dc.w     $A82A
  1440.         EndM
  1441.     ELSE
  1442.         IMPORT    OSAGetDialectInfo
  1443.     ENDIF
  1444.  
  1445. ;
  1446. ;        OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1447. ;        This call gives information about the specified dialect of a scripting
  1448. ;        component. It returns an AEDesc whose type depends on the selector 
  1449. ;        specified. Available selectors are the same as the field keys for a
  1450. ;        dialect info record. The type of AEDesc returned is the same as the 
  1451. ;        type of the field that has same key as the selector.
  1452. ;    
  1453. ;        Errors:
  1454. ;            badComponentInstance    invalid scripting component instance
  1455. ;            errOSASystemError
  1456. ;             errOSABadSelector
  1457. ;            errOSANoSuchDialect:    invalid dialectCode
  1458. ;    
  1459.     IF GENERATING68K THEN
  1460.         Macro
  1461.         _OSAAvailableDialectCodeList
  1462.             dc.w     $2F3C
  1463.             dc.w     $0004
  1464.             dc.w     $0705
  1465.             moveq    #0,d0
  1466.             dc.w     $A82A
  1467.         EndM
  1468.     ELSE
  1469.         IMPORT    OSAAvailableDialectCodeList
  1470.     ENDIF
  1471.  
  1472. ;
  1473. ;        OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1474. ;        This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1475. ;        and  OSAGetDialectInfo to get information on dialects.
  1476. ;        This call return an AEList containing dialect code for each of the
  1477. ;        currently available dialects of a scripting component. Each dialect
  1478. ;        code is a short integer of type typeShortInteger.
  1479. ;    
  1480. ;        Errors:
  1481. ;            badComponentInstance    invalid scripting component instance
  1482. ;            errOSASystemError
  1483. ;
  1484. ;        Type of a dialect info record containing at least keyOSADialectName
  1485. ;        and keyOSADialectCode fields.
  1486. ;
  1487. ;        keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1488. ;
  1489. ;        Field of a typeOSADialectInfo record of typeChar.
  1490. ;        Field of a typeOSADialectInfo record of typeShortInteger.
  1491. ;        Field of a typeOSADialectInfo record of typeShortInteger.
  1492. ;        Field of a typeOSADialectInfo record of typeShortInteger.
  1493. ;    
  1494. ;*************************************************************************
  1495. ;    OSA Optional Event Handling Interface
  1496. ;**************************************************************************
  1497. ;    Scripting components that support the Event Handling interface have the 
  1498. ;    kOSASupportsEventHandling bit set in it's ComponentDescription.
  1499. ;*************************************************************************
  1500.     IF GENERATING68K THEN
  1501.         Macro
  1502.         _OSASetResumeDispatchProc
  1503.             dc.w     $2F3C
  1504.             dc.w     $0008
  1505.             dc.w     $0801
  1506.             moveq    #0,d0
  1507.             dc.w     $A82A
  1508.         EndM
  1509.     ELSE
  1510.         IMPORT    OSASetResumeDispatchProc
  1511.     ENDIF
  1512.  
  1513. ;
  1514. ;        OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1515. ;        This function is used to set the ResumeDispatchProc that will be used
  1516. ;        by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1517. ;        found in the context, or the context event hander "continues" control
  1518. ;        onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1519. ;        may also be passed to this routine indicating that the handler registered
  1520. ;        in the application with AEInstallEventHandler should be used, or no
  1521. ;        dispatch should occur, respectively.
  1522. ;    
  1523. ;        Errors:
  1524. ;            badComponentInstance    invalid scripting component instance
  1525. ;            errOSASystemError
  1526. ;    
  1527. kOSAUseStandardDispatch            EQU        kAEUseStandardDispatch
  1528.  
  1529. ;
  1530. ;        Special ResumeDispatchProc constant which may be passed to 
  1531. ;        OSASetResumeDispatchProc indicating that the handler registered
  1532. ;        in the application with AEInstallEventHandler should be used.
  1533. ;        
  1534. ;        NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1535. ;                doesn't allow pointer types to be assigned to an enum.  All
  1536. ;                constants must be assigned as enums to translate properly to
  1537. ;                Pascal.
  1538. ;    
  1539. kOSANoDispatch                    EQU        kAENoDispatch
  1540.  
  1541. ;
  1542. ;        Special ResumeDispatchProc constant which may be passed to 
  1543. ;        OSASetResumeDispatchProc indicating that no dispatch should occur.
  1544. ;        
  1545. ;        NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1546. ;                doesn't allow pointer types to be assigned to an enum.  All
  1547. ;                constants must be assigned as enums to translate properly to
  1548. ;                Pascal.
  1549. ;    
  1550. kOSADontUsePhac                    EQU        $0001
  1551.  
  1552. ;
  1553. ;        Special refCon constant that may be given to OSASetResumeDispatchProc
  1554. ;        only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1555. ;        This causes the standard dispatch to be performed, except the phac
  1556. ;        handler is not called.  This is useful during tinkerability, when
  1557. ;        the phac handler is used to lookup a context associated with an event's 
  1558. ;        direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1559. ;        bypass the phac handler would result in an infinite loop.
  1560. ;    
  1561.     IF GENERATING68K THEN
  1562.         Macro
  1563.         _OSAGetResumeDispatchProc
  1564.             dc.w     $2F3C
  1565.             dc.w     $0008
  1566.             dc.w     $0802
  1567.             moveq    #0,d0
  1568.             dc.w     $A82A
  1569.         EndM
  1570.     ELSE
  1571.         IMPORT    OSAGetResumeDispatchProc
  1572.     ENDIF
  1573.  
  1574. ;
  1575. ;        OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1576. ;        Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1577. ;        been registered, then kOSAUseStandardDispatch (the default) is returned.
  1578. ;    
  1579. ;        Errors:
  1580. ;            badComponentInstance    invalid scripting component instance
  1581. ;            errOSASystemError
  1582. ;    
  1583.     IF GENERATING68K THEN
  1584.         Macro
  1585.         _OSAExecuteEvent
  1586.             dc.w     $2F3C
  1587.             dc.w     $0010
  1588.             dc.w     $0803
  1589.             moveq    #0,d0
  1590.             dc.w     $A82A
  1591.         EndM
  1592.     ELSE
  1593.         IMPORT    OSAExecuteEvent
  1594.     ENDIF
  1595.  
  1596. ;
  1597. ;        OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1598. ;        This call is similar to OSAExecute except the initial command to
  1599. ;        execute comes in the form of an AppleEvent.  If the contextID
  1600. ;        defines any event handlers for that event, they are used to process
  1601. ;        the event.  If no event handler can be found in the context
  1602. ;        errAEEventNotHandled is returned.  If an event handler is found and
  1603. ;        the hander "continues" control onward, the ResumeDispatchProc
  1604. ;        (registered with OSASetResumeDispatchProc, above) is called given the
  1605. ;        AppleEvent.  The result is returned as a scriptValueID.
  1606. ;    
  1607. ;        Errors:
  1608. ;            badComponentInstance    invalid scripting component instance
  1609. ;            errOSASystemError
  1610. ;            errOSAInvalidID
  1611. ;            errOSAScriptError:        the executing script got an error
  1612. ;            errAEEventNotHandled:    no handler for event in contextID
  1613. ;    
  1614. ;        ModeFlags:
  1615. ;            kOSAModeNeverInteract
  1616. ;            kOSAModeCanInteract
  1617. ;            kOSAModeAlwaysInteract
  1618. ;            kOSAModeCantSwitchLayer
  1619. ;            kOSAModeDontReconnect
  1620. ;            kOSAModeDoRecord
  1621. ;    
  1622.     IF GENERATING68K THEN
  1623.         Macro
  1624.         _OSADoEvent
  1625.             dc.w     $2F3C
  1626.             dc.w     $0010
  1627.             dc.w     $0804
  1628.             moveq    #0,d0
  1629.             dc.w     $A82A
  1630.         EndM
  1631.     ELSE
  1632.         IMPORT    OSADoEvent
  1633.     ENDIF
  1634.  
  1635. ;
  1636. ;        OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1637. ;        This call is similar to OSADoScript except the initial command to
  1638. ;        execute comes in the form of an AppleEvent, and the result is an 
  1639. ;        AppleEvent reply record.  If the contextID defines any event handlers
  1640. ;        for that event, they are used to process the event.  If no event handler
  1641. ;        can be found in the context errAEEventNotHandled is returned.  If an
  1642. ;        event handler is found and the hander "continues" control onward, the
  1643. ;        ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1644. ;        called given the AppleEvent.  The result is returned in the form of an
  1645. ;        AppleEvent reply descriptor. If at any time the script gets an error, or
  1646. ;        if the ResumeDispatchProc returns a reply event indicating an error,
  1647. ;        then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1648. ;        should never return errOSAScriptError).  Any error result returned by
  1649. ;        the ResumeDispatchProc will be returned by OSADoEvent.
  1650. ;    
  1651. ;        Errors:
  1652. ;            badComponentInstance    invalid scripting component instance
  1653. ;            errOSASystemError
  1654. ;            errOSAInvalidID
  1655. ;            errAEEventNotHandled:    no handler for event in contextID
  1656. ;    
  1657. ;        ModeFlags:
  1658. ;            kOSAModeNeverInteract
  1659. ;            kOSAModeCanInteract
  1660. ;            kOSAModeAlwaysInteract
  1661. ;            kOSAModeCantSwitchLayer
  1662. ;            kOSAModeDontReconnect
  1663. ;            kOSAModeDoRecord
  1664. ;    
  1665.     IF GENERATING68K THEN
  1666.         Macro
  1667.         _OSAMakeContext
  1668.             dc.w     $2F3C
  1669.             dc.w     $000C
  1670.             dc.w     $0805
  1671.             moveq    #0,d0
  1672.             dc.w     $A82A
  1673.         EndM
  1674.     ELSE
  1675.         IMPORT    OSAMakeContext
  1676.     ENDIF
  1677.  
  1678. ;
  1679. ;        OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1680. ;        Makes a new empty context which may be passed to OSAExecute or 
  1681. ;        OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1682. ;        created. If parentContext is kOSANullScript then the resulting context
  1683. ;        does not inherit bindings from any other context.
  1684. ;    
  1685. ;        Errors:
  1686. ;            badComponentInstance    invalid scripting component instance
  1687. ;            errOSASystemError
  1688. ;            errOSAInvalidID
  1689. ;            errAECoercionFail:        contextName is invalid
  1690. ;    
  1691.     ENDIF ; __OSA__
  1692.